//
//  HZMType1CVCell.m
//  糖糖大魔王
//
//  Created by 韩震明 on 15/10/31.
//  Copyright © 2015年 韩震明. All rights reserved.
//

#import "HZMType1CVCell.h"
#define WIDTH self.headerImageView.frame.size.width
#define HEIGHT self.headerImageView.frame.size.height
#define FWIDTH self.footerImageView.frame.size.width
#define FHEIGHT self.footerImageView.frame.size.height
@implementation HZMType1CVCell

- (void)dealloc
{
    [_backImageView release];
    [_picImageView release];
    [_priceBackImageView release];
    [_likesImageView release];
    [_buyImageView release];
    [_priceLabel release];
    [_titleLabel release];
    [_likesLabel release];
    [_headerImageView release];
    [_footerImageView release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createItem];
    }
    return self;
}

- (void)createItem
{
    self.backImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.contentView.frame.size.width / 80, 5, self.contentView.frame.size.width - self.contentView.frame.size.width / 40, self.contentView.frame.size.height - 10)];
    [self.contentView addSubview:self.backImageView];
    [_backImageView release];
    self.backImageView.layer.cornerRadius = 5;
    
    self.headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.backImageView.frame.size.width, 8 * self.backImageView.frame.size.height / 9)];
    [self.backImageView addSubview:self.headerImageView];
    [_headerImageView release];
    
    self.picImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 5 * HEIGHT / 6)];
    [self.headerImageView addSubview:self.picImageView];
    [_picImageView release];
    
    self.priceBackImageView = [[UIImageView alloc] initWithFrame:CGRectMake(27 * WIDTH / 40, 13 * HEIGHT / 18, 13 * WIDTH / 40, HEIGHT / 9)];
    [self.picImageView addSubview:self.priceBackImageView];
    [_priceBackImageView release];
    self.priceBackImageView.image = [UIImage imageNamed:@"backOfTitle.png"];
    
    self.priceLabel = [[UILabel alloc] initWithFrame:self.priceBackImageView.frame];
    [self.headerImageView addSubview:self.priceLabel];
    [_priceLabel release];
    self.priceLabel.font = [UIFont systemFontOfSize:15.0];
    self.priceLabel.textColor = [UIColor whiteColor];
    self.priceLabel.textAlignment = NSTextAlignmentCenter;
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH / 140, 20 * HEIGHT / 24, WIDTH - 6, HEIGHT / 6)];
    [self.headerImageView addSubview:self.titleLabel];
    [_titleLabel release];
    self.titleLabel.font = [UIFont systemFontOfSize:13.0];
    self.titleLabel.textColor = [UIColor grayColor];
    
    
    self.footerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 8 * self.backImageView.frame.size.height / 9, self.backImageView.frame.size.width, self.backImageView.frame.size.height / 9)];
    [self.backImageView addSubview:self.footerImageView];
    [_footerImageView release];
    
    self.likesImageView = [[UIImageView alloc] initWithFrame:CGRectMake(1 * FWIDTH / 9, FHEIGHT / 7, FWIDTH / 9, 5 * FHEIGHT / 10)];
    [self.footerImageView addSubview:self.likesImageView];
    [_likesImageView release];
    self.likesImageView.image = [UIImage imageNamed:@"No_Attention.png"];
    
    self.likesLabel = [[UILabel alloc] initWithFrame:CGRectMake(2 * FWIDTH / 9, FHEIGHT / 7, 2 * FWIDTH / 9, 5 * FHEIGHT / 10)];
    [self.footerImageView addSubview:self.likesLabel];
    [_likesLabel release];
    self.likesLabel.font = [UIFont systemFontOfSize:9.0];
    self.likesLabel.textAlignment = NSTextAlignmentCenter;
    
    self.buyImageView = [[UIImageView alloc] initWithFrame:CGRectMake(5 * FWIDTH / 9, FHEIGHT / 7, FWIDTH / 9, 5 * FHEIGHT / 10)];
    [self.footerImageView addSubview:self.buyImageView];
    [_buyImageView release];
    self.buyImageView.image = [UIImage imageNamed:@"buy_car.png"];
    
}

@end
